package com.vtuzx.kingdee.xqc_core.dao;

import com.vtuzx.core.db.mongo.impl.VtuzxDaoImpl;
import com.vtuzx.kingdee.xqc_core.bean.VtuzxArrayList;
import org.bson.Document;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * 对接系统接口履历Dao
 */
@Component
public class PrdPickDetailDao extends VtuzxDaoImpl {
    /** 集合名称 */
    public static final String NAME = "t_prd_pick_detail";

    public PrdPickDetailDao() {
        super(NAME);
    }

    /**
     * 用于物料收发明细（计算所有出库数量）期初
     * @param cond
     * @return
     */
//    public Iterator<Document> findOutDetail(Criteria cond) {
//        List<Document> docList = new ArrayList<>();
//        docList.add(new Document("$group", new Document("_id", "any").append("tableA", new Document("$push", "$$ROOT"))));
//        docList.add(new Document("$lookup", new Document("from", PrdPickDetailDao.NAME).append("foreignField", "xxx1").append("localField", "xxx2").append("as", PrdPickDetailDao.NAME)));
//        docList.add(new Document("$lookup", new Document("from", OtherOutDetailDao.NAME).append("foreignField", "xxx1").append("localField", "xxx2").append("as", OtherOutDetailDao.NAME)));
//        docList.add(new Document("$lookup", new Document("from", SaleOutDetailDao.NAME).append("foreignField", "xxx1").append("localField", "xxx2").append("as", SaleOutDetailDao.NAME)));
//        docList.add(new Document("$lookup", new Document("from", AllocationDetailDao.NAME).append("foreignField", "xxx1").append("localField", "xxx2").append("as", AllocationDetailDao.NAME)));
//        docList.add(new Document("$project", new Document("_id", null).append("allValue", new Document("$setUnion", new VtuzxArrayList<>("$tableA", "$"+PrdPickDetailDao.NAME,"$"+OtherOutDetailDao.NAME,"$"+SaleOutDetailDao.NAME,"$"+AllocationDetailDao.NAME)))));
//        docList.add(new Document("$unwind", new Document("path", "$allValue")));
//
//        docList.add(new Document("$match", cond.getCriteriaObject()));
//
//        return this.aggregate(docList);
//    }

}